<!Doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<title></title>
</head>
<body>
	<input type="text" id="weight" placeholder="体重（kg）">
	<input type="text" id="height" placeholder="身高（m）">
	<div id="box" class="box">
		
	</div>
	<input type="button" value="计算BMI" id="btn">
	<script>
	var boxObj = document.getElementById('box');
	var btn = document.getElementById('btn');

	function bmi() {
		var height = document.getElementById('height').value;
		var weight = document.getElementById('weight').value;
		var BMI = weight/(height*height);   //height weight字符串隐式转换为数字
		boxObj.innerHTML = '您的身高为：'+ height +'m,您的体重为：'+ weight +'kg,<br/>您的BMI指数为：' + BMI;
	}
	btn.onclick = bmi;  //函数作为数据类型赋值；
	// btn.onclick = bmi() ;  函数的调用，当代码执行到这行时，会调用并执行函数
	</script>
</body>
</html>